# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=bzrtp
pkgver=5.3.38
pkgrel=0
pkgdesc="BZRTP is an opensource implementation of ZRTP keys exchange protocol"
url="https://gitlab.linphone.org/BC/public/bzrtp"
arch="all"
license="GPL-3.0-only"
makedepends="cmake bctoolbox-dev sqlite-dev libxml2-dev samurai"
subpackages="$pkgname-dev"
source="https://gitlab.linphone.org/BC/public/bzrtp/-/archive/$pkgver/bzrtp-$pkgver.tar.gz
	fix-cmake-path.patch
	fix-pkgconfig-pc-file.patch
	"
options="!check" # need bctoolbox-tester

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DENABLE_STATIC=False \
		-DENABLE_STRICT=False \
		-DENABLE_TESTS="$(want_check && echo ON || echo OFF)" \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
bc4ea6ed0bbe0cd3302c5e0a6a9cf06ba13c4d287558f896545649732612430d51b87be0e48e5539fd10429518967711427d772f583551327d421ec1691d29fa  bzrtp-5.3.38.tar.gz
87770c9fb75dce9a06343ce672323e68e8115c97fe21f74ec96161fdc2b91f09be243cc80952db65078b045fcca100fb814a06c78c5a6f83f137df96170da16c  fix-cmake-path.patch
546349c5fa485b0f8fcb099c0485c30489e2b8d1e50e7a77404be9a22b0282fa207f5b1b74e679d917f579f00432fa54dfd7b045a9f30dc5f259377013ef924b  fix-pkgconfig-pc-file.patch
"
